home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / ibmplat1.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  5KB  |  195 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    ibmpc_latin1
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. #define DOS_EOF    0x1A        /* MS-DOS old end-of-file */
  25.  
  26. static const char *translation_table[128] =
  27.   {
  28.     "\307",            /* \200  C, */
  29.     "\374",            /* \201  u" */
  30.     "\351",            /* \202  e' */
  31.     "\342",            /* \203  a^ */
  32.     "\344",            /* \204  a" */
  33.     "\340",            /* \205  a` */
  34.     "\345",            /* \206  aa */
  35.     "\347",            /* \207  c, */
  36.     "\352",            /* \210  e^ */
  37.     "\353",            /* \211  e" */
  38.     "\350",            /* \212  e` */
  39.     "\357",            /* \213  i" */
  40.     "\356",            /* \214  i^ */
  41.     "\354",            /* \215  i` */
  42.     "\304",            /* \216  A" */
  43.     "\305",            /* \217  AA */
  44.     "\311",            /* \220  E' */
  45.     "\346",            /* \221  ae */
  46.     "\306",            /* \222  AE */
  47.     "\364",            /* \223  o^ */
  48.     "\366",            /* \224  o" */
  49.     "\362",            /* \225  o` */
  50.     "\373",            /* \226  u^ */
  51.     "\371",            /* \227  u` */
  52.     "\377",            /* \230  y" */
  53.     "\326",            /* \231  O" */
  54.     "\334",            /* \232  U" */
  55.     "\242",            /* \233  \cent */
  56.     "\243",            /* \234  \pound */
  57.     "\245",            /* \235  \yen */
  58.     "<Pt>",            /* \236 */
  59.     "<f>",            /* \237 */
  60.     "\341",            /* \240  a' */
  61.     "\355",            /* \241  i' */
  62.     "\363",            /* \242  o' */
  63.     "\372",            /* \243  u' */
  64.     "\361",            /* \244  n~ */
  65.     "\321",            /* \245  N~ */
  66.     "\252",            /* \246  a_ */
  67.     "\272",            /* \247  o_ */
  68.     "\277",            /* \250  ?' */
  69.     "<->",            /* \251 */
  70.     "\254",            /* \252  \neg */
  71.     "\274",            /* \253  1/2 */
  72.     "\273",            /* \254  1/4 */
  73.     "\241",            /* \255  !` */
  74.     "\253",            /* \256  `` */
  75.     "\273",            /* \257  '' */
  76.     "#",            /* \260 */
  77.     "#",            /* \261 */
  78.     "#",            /* \262 */
  79.     "|",            /* \263 */
  80.     "+",            /* \264 */
  81.     "|",            /* \265 */
  82.     "+",            /* \266 */
  83.     "+",            /* \267 */
  84.     "=",            /* \270 */
  85.     "=",            /* \271 */
  86.     "|",            /* \272 */
  87.     "=",            /* \273 */
  88.     "=",            /* \274 */
  89.     "+",            /* \275 */
  90.     "=",            /* \276 */
  91.     "+",            /* \277 */
  92.     "+",            /* \300 */
  93.     "+",            /* \301 */
  94.     "+",            /* \302 */
  95.     "+",            /* \303 */
  96.     "-",            /* \304 */
  97.     "+",            /* \305 */
  98.     "|",            /* \306 */
  99.     "+",            /* \307 */
  100.     "=",            /* \310 */
  101.     "=",            /* \311 */
  102.     "=",            /* \312 */
  103.     "=",            /* \313 */
  104.     "=",            /* \314 */
  105.     "=",            /* \315 */
  106.     "=",            /* \316 */
  107.     "=",            /* \317 */
  108.     "+",            /* \320 */
  109.     "=",            /* \321 */
  110.     "+",            /* \322 */
  111.     "+",            /* \323 */
  112.     "=",            /* \324 */
  113.     "=",            /* \325 */
  114.     "+",            /* \326 */
  115.     "+",            /* \327 */
  116.     "=",            /* \330 */
  117.     "+",            /* \331 */
  118.     "+",            /* \332 */
  119.     "#",            /* \333 */
  120.     "#",            /* \334 */
  121.     "#",            /* \335 */
  122.     "#",            /* \336 */
  123.     "#",            /* \337 */
  124.     "<alpha>",            /* \340 */
  125.     "\337",            /* \341  \ss */
  126.     "<Gamma>",            /* \342 */
  127.     "<pi>",            /* \343 */
  128.     "<Sigma>",            /* \344 */
  129.     "<sigma>",            /* \345 */
  130.     "\265",            /* \346  \micro */
  131.     "<tau>",            /* \347 */
  132.     "<Phi>",            /* \350 */
  133.     "<Theta>",            /* \351 */
  134.     "<Omega>",            /* \352 */
  135.     "<delta>",            /* \353 */
  136.     "<infty>",            /* \354 */
  137.     "<phi>",            /* \355 */
  138.     "<in>",            /* \356 */
  139.     "<cap>",            /* \357 */
  140.     "<equiv>",            /* \360 */
  141.     "\261",            /* \361  +- */
  142.     ">=",            /* \362 */
  143.     "<=",            /* \363 */
  144.     "<integ1>",            /* \364 */
  145.     "<integ2>",            /* \365 */
  146.     "\327",            /* \366  \div */
  147.     "<approx>",            /* \367 */
  148.     "\260",            /* \370  \deg */
  149.     "<*>",            /* \371 */
  150.     "\267",            /* \372  \cdot */
  151.     "<surd>",            /* \373 */
  152.     "<^n>",            /* \374 */
  153.     "\262",            /* \375  ^2 */
  154.     "<#>",            /* \376 */
  155.     "\240",            /* \377  \  */
  156.   };
  157.  
  158. void
  159. STEP (FILE *input_file, FILE *output_file)
  160. {
  161.   int input_char;        /* current character */
  162.   const char *output_string;    /* translated characters */
  163.  
  164.   input_char = getc (input_file);
  165.   while (input_char != EOF && input_char != DOS_EOF)
  166.     if ((input_char & 0377) < 0200)
  167.       if (input_char == 0x0D)
  168.     {
  169.       input_char = getc (input_file);
  170.       if (input_char == 0x0A)
  171.         {
  172.           putc ('\n', output_file);
  173.           input_char = getc (input_file);
  174.         }
  175.       else
  176.         putc (0x0D, output_file);
  177.     }
  178.       else
  179.     {
  180.       putc (input_char, output_file);
  181.       input_char = getc (input_file);
  182.     }
  183.     else
  184.       {
  185.     if (output_string = translation_table[input_char & 0177],
  186.         output_string)
  187.       while (*output_string)
  188.         {
  189.           putc (*output_string, output_file);
  190.           output_string++;
  191.         }
  192.     input_char = getc (input_file);
  193.       }
  194. }
  195.